//https://leetcode.cn/problems/arithmetic-slices/

class Solution {
public:
    int numberOfArithmeticSlices(vector<int>& nums) {
        int n = nums.size();

        vector<int> dp(n);
        int ret = 0;

        for (int i = 2; i < n; i++)
        {
            dp[i] = (nums[i - 1] - nums[i - 2] == nums[i] - nums[i - 1]) ? dp[i - 1] + 1 : 0;
            ret += dp[i];
        }

        return ret;

    }
};